Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add builder methods to exp.Update and add with_ arg to exp.update #4217

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

brdbry
Copy link
Contributor

@brdbry brdbry commented Oct 7, 2024

Improve ergonomics of UPDATEs:

  • Add builder methods to Update class so it can be constructed incrementally in the same way a Select
  • exp.update changes:
    • Add a with_ arg so updates with CTEs can be created in one-shot without subsequent need to .set(...) the With clause
    • Make the properties arg optional, so set_ builder method can be used with an AST (exp.update("tbl").set_(set_expr) ) instead of forcing specification as a dict

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few comments. Thanks a lot for the PR, @brdbry!

sqlglot/expressions.py Outdated Show resolved Hide resolved
sqlglot/expressions.py Outdated Show resolved Hide resolved
sqlglot/expressions.py Show resolved Hide resolved
sqlglot/expressions.py Outdated Show resolved Hide resolved
@georgesittas georgesittas changed the title Update improvements: add builder methods to exp.Update and add with_ arg to exp.update Feat: add builder methods to exp.Update and add with_ arg to exp.update Oct 7, 2024
…e suggestion that CTE query in with_ must be a Select (can include set operators)
@georgesittas georgesittas merged commit 354cfff into tobymao:main Oct 7, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants